package com.kethink;

import java.util.Stack;

/**
 * @Description :
 * @Author: demo
 * @Date: 2018/12/26 23:36
 * Copyright (C), 2017-2018, 沃顿信息科技有限公司
 */
public class LeeCode_832 {

    public static int[][] flipAndInvertImage(int[][] A) {

        for(int i = 0 ; i < A.length; i++){
            Stack stack = new Stack();
            for(int j = 0 ; j < A[i].length ; j ++){
                //先水平翻转，用栈来存放
                stack.push(A[i][j]);
            }
            for(int j = 0 ; j < A[i].length ; j ++){
                //三元运算符取反
                A[i][j] = (int)stack.pop()==0?1:0;
            }
        }
        return A;
    }

    public static void main(String[] args){
        int[][] A = {{1,1,0},{1,0,1},{0,0,0}};
        //  [[1,0,0],[0,1,0],[1,1,1]]
        System.out.println(flipAndInvertImage(A));
    }
}
